﻿using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.ComponentModel;
using System.Linq;
using System.Runtime.CompilerServices;
using System.Text;
using System.Threading.Tasks;

namespace AngleExpress.viewmodel
{
    public class ContentViewModel : NotifyBase
    {
        public string UserName { get; set; }
        public int JoinDay { get; set; }

        public string Version { get; set; }
        
        public string Name
        {
            get
            {
                return name;
            }
            set
            {
                name = value;
                RaisePropertyChanged("Name");
            }
        }
        public string CompanyName
        {
            get
            {
                return companyName;
            }
            set
            {
                companyName = value;
                RaisePropertyChanged("CompanyName");
            }
        }
        public string Phone
        {
            get
            {
                return phone;
            }
            set
            {
                phone = value;
                RaisePropertyChanged("Phone");
            }
        }
        public bool Loading
        {
            get
            {
                return loading;
            }
            set
            {
                loading = value;
                RaisePropertyChanged("Loading");
            }
        }
        public string NotifyCount
        {
            get
            {
                return notifyCount;
            }
            set
            {
                notifyCount = value;
                RaisePropertyChanged();
                RaisePropertyChanged("ShowNotify");
            }
        }
        public bool ShowNotify
        {
            get
            {
                return NotifyCount != "0";
            }
        }
        public ObservableCollection<SoftwareGroup> SoftwareGroups
        {
            get
            {
                return softwareGroups;
            }
            set
            {
                softwareGroups = value;
                RaisePropertyChanged("SoftwareGroups");
            }
        }
        public ObservableCollection<ProxyUser> ProxyUsers
        {
            get
            {
                return proxyUsers;
            }
            set
            {
                proxyUsers = value;
                RaisePropertyChanged("ProxyUsers");
            }
        }

        private string name;
        private string companyName;
        private string phone;
        private bool loading;
        private string notifyCount;
        private ObservableCollection<ProxyUser> proxyUsers = new ObservableCollection<ProxyUser>();
        private ObservableCollection<SoftwareGroup> softwareGroups = new ObservableCollection<SoftwareGroup>();

        
    }

    

    public class ProxyUser:NotifyBase
    {
        public string ID { get; set; }
        
        public string ProxyUserName { get; set; }
       
        public bool Selected
        {
            get
            {
                return selected;
            }
            set
            {
                selected = value;
                RaisePropertyChanged();
            }
        }

        private bool selected;
    }

    public class SoftwareInfo: NotifyBase
    {
        public string SoftwareName { get; set; }
        public string UserName { get; set; }
        public string Password { get; set; }
        public string OtherParam { get; set; }
        public ProgramCategory Category { get; set; }
        public string IconUrl { get; set; }
        public string Code { get; set; }
        public string SoftwareID { get; set; }

    }

    public class SoftwareGroup: NotifyBase
    {
        public string GroupName { get; set; }
        public ObservableCollection<SoftwareInfo> Softwares
        {
            get
            {
                return softwares;
            }
            set
            {
                softwares = value;
                RaisePropertyChanged();
            }
        }

        private ObservableCollection<SoftwareInfo> softwares = new ObservableCollection<SoftwareInfo>();
    }

    public enum ProgramCategory
    { 
        DeskTop = 1,//api参数定义需要
        Web
    }


    public class NotifyBase: INotifyPropertyChanged
    {
        public event PropertyChangedEventHandler PropertyChanged;
        public void RaisePropertyChanged([CallerMemberName] string propertyName = "")
        {
            PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
        }
    }
}
